package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.ExperienceMapper;
import com.lune.job.pojo.Experience;
import com.lune.job.pojo.ResPageBean;
import com.lune.job.service.IExperienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class ExperienceServiceImpl extends ServiceImpl<ExperienceMapper, Experience> implements IExperienceService {


    @Autowired
    private ExperienceMapper experienceMapper;

    /**
     * 分页查询工作经历
     * @param currentPage
     * @param size
     * @param experience
     * @return
     */
    @Override
    public ResPageBean queryPage(Integer currentPage, Integer size, Experience experience) {
        Page<Experience> page = new Page<>(currentPage, size);
        IPage<Experience> companyIPage = experienceMapper.getAllCompanyByPage(page,experience);
        ResPageBean resPageBean = new ResPageBean(companyIPage.getTotal(), companyIPage.getPages(), companyIPage.getRecords());
        return  resPageBean;
    }

    /**
     * 条件查询工作经历
     * @param experience
     * @return
     */
    @Override
    public List<Experience> queryByCon(Experience experience) {
        return experienceMapper.queryByCon(experience);
    }
}
